#!/usr/bin/env node

const log = console.log,
      http = require('http'),
      msg = process.argv[2] || 'hello server',
      addr = 'http://localhost:8080',
      url = require('url');

let opt  = url.parse(addr);
opt.method = 'POST';

//send request 
let req = http.request(opt,(res)=>{ 
  log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);

  log(res.headers);

  res.pipe(process.stdout);
});

//write data
req.end(msg);
